import time

from tools.base_page import BasePage


class Seacher(BasePage):


    def seacher_res_all(self):
        data_locator = ('xpath', '//*[@resource-id ="com.znb.zxx:id/comm_item_course_title"]')
        if len(self.elements(data_locator)) > 1:
            return True
        else:
            return False

    def search_res_course(self):
        courese_title = ("id", 'comm_item_course_title')
        course_locator = ('id', 'tab_title')
        self.elements(course_locator)[1].click()
        self.elements(courese_title)[0].click()
        time.sleep(1)
        self.driver.back()

    def search_res_gonggao(self):
        gonggao_locator = ("xpath", "//*[@text='公告']")
        first_notice = ('id', 'item_search_bulletin_title')
        self.find(gonggao_locator).click()
        self.elements(first_notice)[0].click()
        time.sleep(1)
        self.back_activity(1)

    def search_res_job(self):
        job_locator = ("xpath", "//*[@text='职位']")
        first_job = ('id', 'item_job_title')
        self.find(job_locator).click()
        self.elements(first_job)[0].click()
        time.sleep(1)
        self.back_activity(1)

    def search_res_news(self):
        news_locator = ("xpath", "//*[@text='资讯']")
        first_new = ('id', 'comm_item_news_title')
        self.find(news_locator).click()
        self.elements(first_new)[0].click()
        time.sleep(1)
        self.page(self.index)
        return True
        # self.back_activity(2)
        # from po.index_page import IndexPage
        # return IndexPage(self.driver)
